package com.hhl.controller;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hhl.entity.StudentInfo;


@Controller
public class IndexController {
	Logger logger = LoggerFactory.getLogger(IndexController.class);

	@RequestMapping("/index")
	@ResponseBody
	public String index(Map<String, Object> map) {
		logger.info("log4j打印日志");
		map.put("name", "HelloWorld");
		int i = 1/0;
		return "index";
	}

	@RequestMapping("/freemarkerIndex")
	public String index2(Map<String, Object> result) {
		result.put("name", "何海龙");
		result.put("age", "19");
		result.put("sex", "0");

		List<StudentInfo> list = new ArrayList<StudentInfo>();
		StudentInfo info = new StudentInfo();
		info.setAge("19");
		info.setName("何海龙");
		info.setSex("0");
		list.add(info);

		StudentInfo info1 = new StudentInfo();
		info1.setAge("20");
		info1.setName("李四");
		info1.setSex("1");
		list.add(info1);
		result.put("list", list);

		List<String> list2 = new ArrayList<>();
		list2.add("你好");
		list2.add("springboot");
		result.put("list2", list2);

		return "index";
	}
}
